package com.qfmy.mapper.novel;


import model.entity.novel.History;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.mapper.novel
 * @date 2025/6/6
 * @description 小说的历史
 */
@Mapper
@SuppressWarnings("all")
public interface HistoryMapper {

    /**
     *
     * @param userId
     * @return
     */
    List<Long> selectHistortByUserId(Long userId);

    /**
     * 获取最新的阅读记录
     * @param userId
     * @return
     */
    History selectNewestHistoryByUserId(@Param("userId") Long userId);

    /**
     * 获取阅读记录
     * @param userId
     * @param start
     * @param size
     * @return
     */
    List<History> getHistoryByPage(Long userId, Integer start, Integer size);

    /**
     * 清除阅读记录
     * @param userId
     */
    @Delete("delete from history where user_id = #{userId}")
    void clearHistory(Long userId);

    /**
     * 清除阅读记录
     * @param historyId
     * @param userId
     */
    @Delete("delete from history where id = #{historyId} and user_id = #{userId}")
    void clearHistoryById(Long historyId, Long userId);

    /**
     * 根据用户id+章节id查询历史记录
     * @param userId
     * @param novelId
     * @return
     */
    History selectHistory(Long userId, Long novelId);

    /**
     * 保存阅读记录
     * @param history
     */
    void insert(History history);

    /**
     * 更新阅读记录
     * @param history
     */
    void update(History history);
}
